package com.kldy8.kldyw;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2016/7/25.
 * 认证
 */
public class AuthenticationGridViewAdapter extends BaseAdapter
{

    private List<HashMap<String, GridViewItem>> list;
    private GridViewItem tempGridViewItem;
    private LayoutInflater layoutInflater;

    public AuthenticationGridViewAdapter(Context context,
                     List<HashMap<String, GridViewItem>> list)
    {
        this.list = list;
        layoutInflater = LayoutInflater.from(context);
    }
    @Override
    public int getCount()
    {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {
        View view = null;

        if (layoutInflater != null)
        {
            view = layoutInflater
                    .inflate(R.layout.authentication_item, null);
            ImageView imageView = (ImageView) view
                    .findViewById(R.id.imageView1);
            TextView titleView = (TextView) view.findViewById(R.id.title);
            TextView introductionView = (TextView) view.findViewById(R.id.introduction);
            ImageView sureView = (ImageView) view.findViewById(R.id.is_sure);
            //获取自定义的类实例
            tempGridViewItem = list.get(i).get("item");
            imageView.setImageBitmap(tempGridViewItem.bitmap);
            titleView.setText(tempGridViewItem.title);
//            sureView.setImageBitmap(tempGridViewItem.isbitmap);
            introductionView.setText(tempGridViewItem.introduction);
        }
        return view;    }
}
 class GridViewItem
{
    public Bitmap bitmap;// 图片
    public String title;// 题标
    public String introduction;// 简介
    public Bitmap isbitmap;// 图片

    // 待扩展
    public GridViewItem() {
    }

    public GridViewItem(Bitmap bitmap, String title,String introduc)
    {
        super();
        this.bitmap = bitmap;
        this.title = title;
        this.introduction = introduc;
    }

}
